package net.comic.entities

import org.codehaus.groovy.grails.commons.GrailsResourceUtils

class User {
	def grailsApplication
	
	//	Persistence Attributes
	String 	name
	String 	lastName
	String 	email
	String 	alias
    String  password
    String  country
    String  avatarPath
    Date 	birdDay
    boolean male		= 	true
    boolean admin 		= 	false
    boolean disabled	=	false	

	Date 	dateCreated
	Date 	lastUpdated
	
	
	//	Not Persistence Attributes
	static 	transients = ['absoluteImagePath']	

	
	//	DB Relations
	static 	hasMany = 	[favoritesComics:		Comic]
	
	       	          	 
	//	DB Constraits
	static constraints = {
		name(blank:false)
		lastName(blank:false)
		alias(blank:false, unique:true)
		email(blank:false,email:true)
        password(blank:false)
        avatarPath(nullable:true)  
	}
	
	
	String getAbsoluteImagePath() {
		return grailsApplication.config.comics.uploadAbsoluteAvatarPath + avatarPath
	}
	
	String getAbsoluteImagePath(file) {
		return grailsApplication.config.comics.uploadAbsoluteAvatarPath + file + "/"
	}
}
